Optimal. Leaf size=80 \[ 2 a^2 (A-i B) x-\frac {2 a^2 (i A+B) \log (\cos (e+f x))}{f}-\frac {a^2 (A-i B) \tan (e+f x)}{f}+\frac {B (a+i a \tan (e+f x))^2}{2 f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.05, antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 3, integrand size = 26, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.115, Rules used = {3608, 3558,
3556} \begin {gather*} -\frac {a^2 (A-i B) \tan (e+f x)}{f}-\frac {2 a^2 (B+i A) \log (\cos (e+f x))}{f}+2 a^2 x (A-i B)+\frac {B (a+i a \tan (e+f x))^2}{2 f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3556
Rule 3558
Rule 3608
Rubi steps
\begin {align*} \int (a+i a \tan (e+f x))^2 (A+B \tan (e+f x)) \, dx &=\frac {B (a+i a \tan (e+f x))^2}{2 f}-(-A+i B) \int (a+i a \tan (e+f x))^2 \, dx\\ &=2 a^2 (A-i B) x-\frac {a^2 (A-i B) \tan (e+f x)}{f}+\frac {B (a+i a \tan (e+f x))^2}{2 f}+\left (2 a^2 (i A+B)\right ) \int \tan (e+f x) \, dx\\ &=2 a^2 (A-i B) x-\frac {2 a^2 (i A+B) \log (\cos (e+f x))}{f}-\frac {a^2 (A-i B) \tan (e+f x)}{f}+\frac {B (a+i a \tan (e+f x))^2}{2 f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(263\) vs. \(2(80)=160\).
time = 1.16, size = 263, normalized size = 3.29 \begin {gather*} \frac {a^2 \sec (e) \sec ^2(e+f x) (\cos (2 f x)+i \sin (2 f x)) \left (-8 (A-i B) \text {ArcTan}(\tan (3 e+f x)) \cos (e) \cos ^2(e+f x)-i \left (4 i A f x \cos (3 e+2 f x)+4 B f x \cos (3 e+2 f x)+(i A+B) \cos (e+2 f x) \left (4 f x-i \log \left (\cos ^2(e+f x)\right )\right )+A \cos (3 e+2 f x) \log \left (\cos ^2(e+f x)\right )-i B \cos (3 e+2 f x) \log \left (\cos ^2(e+f x)\right )+2 \cos (e) \left (-i B+4 i A f x+4 B f x+(A-i B) \log \left (\cos ^2(e+f x)\right )\right )+2 i A \sin (e)+4 B \sin (e)-2 i A \sin (e+2 f x)-4 B \sin (e+2 f x)\right )\right )}{4 f (\cos (f x)+i \sin (f x))^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.11, size = 76, normalized size = 0.95
method | result | size |
derivativedivides | \(\frac {a^{2} \left (-\frac {B \left (\tan ^{2}\left (f x +e \right )\right )}{2}-A \tan \left (f x +e \right )+2 i B \tan \left (f x +e \right )+\frac {\left (2 i A +2 B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-2 i B +2 A \right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) | \(76\) |
default | \(\frac {a^{2} \left (-\frac {B \left (\tan ^{2}\left (f x +e \right )\right )}{2}-A \tan \left (f x +e \right )+2 i B \tan \left (f x +e \right )+\frac {\left (2 i A +2 B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-2 i B +2 A \right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) | \(76\) |
norman | \(\left (-2 i B \,a^{2}+2 a^{2} A \right ) x -\frac {\left (-2 i B \,a^{2}+a^{2} A \right ) \tan \left (f x +e \right )}{f}-\frac {a^{2} B \left (\tan ^{2}\left (f x +e \right )\right )}{2 f}+\frac {\left (i A \,a^{2}+a^{2} B \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{f}\) | \(87\) |
risch | \(\frac {4 i a^{2} B e}{f}-\frac {4 a^{2} A e}{f}-\frac {2 a^{2} \left (i A \,{\mathrm e}^{2 i \left (f x +e \right )}+3 B \,{\mathrm e}^{2 i \left (f x +e \right )}+i A +2 B \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}-\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B}{f}-\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A}{f}\) | \(120\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.55, size = 75, normalized size = 0.94 \begin {gather*} -\frac {B a^{2} \tan \left (f x + e\right )^{2} - 4 \, {\left (f x + e\right )} {\left (A - i \, B\right )} a^{2} - 2 \, {\left (i \, A + B\right )} a^{2} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 2 \, {\left (A - 2 i \, B\right )} a^{2} \tan \left (f x + e\right )}{2 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 1.73, size = 127, normalized size = 1.59 \begin {gather*} -\frac {2 \, {\left ({\left (i \, A + 3 \, B\right )} a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A + 2 \, B\right )} a^{2} + {\left ({\left (i \, A + B\right )} a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, {\left (i \, A + B\right )} a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A + B\right )} a^{2}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )\right )}}{f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [A]
time = 0.32, size = 122, normalized size = 1.52 \begin {gather*} - \frac {2 i a^{2} \left (A - i B\right ) \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{f} + \frac {- 2 i A a^{2} - 4 B a^{2} + \left (- 2 i A a^{2} e^{2 i e} - 6 B a^{2} e^{2 i e}\right ) e^{2 i f x}}{f e^{4 i e} e^{4 i f x} + 2 f e^{2 i e} e^{2 i f x} + f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 228 vs. \(2 (73) = 146\).
time = 0.58, size = 228, normalized size = 2.85 \begin {gather*} -\frac {2 \, {\left (i \, A a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + B a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 2 i \, A a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 2 \, B a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, A a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + 3 \, B a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + i \, A a^{2} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + B a^{2} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, A a^{2} + 2 \, B a^{2}\right )}}{f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 8.54, size = 76, normalized size = 0.95 \begin {gather*} \frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (2\,B\,a^2+A\,a^2\,2{}\mathrm {i}\right )}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a^2\,\left (B+A\,1{}\mathrm {i}\right )\,1{}\mathrm {i}+B\,a^2\,1{}\mathrm {i}\right )}{f}-\frac {B\,a^2\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________